package com.centerm.eterm.ui.accountService;

import com.centerm.eterm.data.GlobalData;
import com.centerm.eterm.module.ExecUtil;
import com.centerm.eterm.ui.tool.Serial.SerialBean;

public class Test
{
	static String		szApn		= "cmnet";
	static String		szUser		= "";
	static String		szPassword	= "";
	static String		szApnCall	= "*99***1#";
	static SerialBean	SB;
	static String		szLine		= "";
	static String		szChar		= "";

	/**
	 * @param args
	 */
	public static boolean ProcessLine(String szLine)
	{
		if (szLine.isEmpty() || szLine.equals("") || szLine == null || szLine.equals(null))
		{
			return false;
		}
		else if (szLine.indexOf("OK") != -1)
		{
			return true;
		}
		else if (szLine.indexOf("ERROR") != -1)
		{
			return true;
		}
		else if (szLine.indexOf("AT") != -1 || szLine.indexOf("AT+") != -1 || szLine.indexOf("AT^") != -1 || szLine.indexOf("ATI") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^BOOT:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^SRVST:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^DSFLOWRPT:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^MODE:") != -1 && GlobalData.b3GConnect == true)
		{
			return false;
		}
		else if (szLine.indexOf("^SYSINFO:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("Manufacturer:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^RSSI:") != -1 && GlobalData.b3GConnect == true)
		{
			return false;
		}
		else if (szLine.indexOf("CSQ:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("Model:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("Revision:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("IMEI:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("^HWVER:") != -1)
		{
			return false;
		}
		else if (szLine.indexOf("COPS:") != -1)
		{
			return false;
		}
		else
		{
			return false;
		}
	}

	public static void main(String[] args)
	{
		String CreateCMD[] =
		{ "C:\\Program Files\\centerm\\ccb\\bin\\3GConnect.exe", "-c", "CM", "cmnet" };
		StringBuffer CreateRet = ExecUtil.execCmdWithReturn(CreateCMD);
		// if ( !CreateRet.toString().equals("1") )
		// {
		// }
		String DialCMD[] =
		{ "C:\\Program Files\\centerm\\ccb\\bin\\3GConnect.exe", "-d", "a", "a", "*99***1#" };
		StringBuffer DialRet = ExecUtil.execCmdWithReturn(DialCMD);
		// if ( !DialRet.toString().equals("1") )
		// {
		// }
		SB = new SerialBean(13);
		SB.Initialize(9600, 8, 1, 0, "");
		SB.WriteStrToPort("AT^HWVER\r\n");
		while (true)
		{
			szChar = SB.ReadCharFromPort();
			System.out.print(szChar);
			// if ( szChar.equals("\n") )
			// {
			// System.out.print(szLine);
			// ProcessLine(szLine);
			// break;
			// }
			// else
			// {
			// szLine += szChar;
			// }
		}
	}

}
